package com.config;

import com.framework.filter.HttpFilter;
import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

import javax.servlet.Filter;

public class WebAppConfig extends AbstractAnnotationConfigDispatcherServletInitializer {
    @Override
    protected Class<?>[] getRootConfigClasses() {
        return new Class[]{RootConfig.class};
    }

    @Override
    protected Class<?>[] getServletConfigClasses() {
        return new Class[]{WebServletConfig.class};
    }

    @Override
    protected String[] getServletMappings() {
        return new String[]{"/"};
    }

    @Override
    protected Filter[] getServletFilters() {
        //解决中文乱码
        CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter( "UTF-8",true );
        //属性设置
        HttpFilter httpFilter = new HttpFilter();
        return new  Filter[] {characterEncodingFilter,httpFilter};
    }
}
